//Clear all data
clear all

//Set numeric type
set type double

//Set width of figure
local widthPix = 5000


// Change directory - Alter this command to the local copy of the "PrimaryModel" directory
*cd "/Users/connorforsythe/Library/CloudStorage/Box-Box/CMU/Marginal Mileage Project/Publication Replication Code/JAERE/PrimaryModel"
// cd "C:/Users/akshayaj/Box/JAERE/PrimaryModel/"
cd "/Users/connorforsythe/Library/CloudStorage/Box-Box/CMU/Marginal Mileage Project/Publication Replication Code/JAERE/PrimaryModel"

//Prevent graphics from popping up while running code
set graphics off

//Always close log regardless of error
capture log close
//determine log location depending on OS
if("`c(os)'"=="Windows"){
	log using "ReviewResponseResults\ReviewResponse.smcl", replace
	local tableSaveDir = "ReviewResponseResults\"
	local plotSaveDir = "ReviewResponseResults\"
	local pythonSaveDir = "PythonScripts\"
}
else{
	log using "ReviewResponseResults/ReviewResponse.smcl", replace
	local tableSaveDir = "ReviewResponseResults/"
	local plotSaveDir = "ReviewResponseResults/"
	local pythonSaveDir = "PythonScripts/"
}


//Start Timer
timer on 1

//Load useful programs
do programs

// // //Execute Stata Do File to load and clean the data for VMT models
do LoadDataVMT

// Urban-Rural models
capture frame drop ruralUrban
capture drop ruralUrban ruralvmt urbanvmt logruralvmt logurbanvmt
do VMTIVUrbanRural

//Interacted treatment with metro population share
do RegDiDMetro

// Urban-Rural Reduced Form Comparison
capture frame drop ruralUrban
capture drop ruralUrban ruralvmt urbanvmt logruralvmt logurbanvmt
do VMTRFRuralUrban

//Emissions Controls
do RegDIDEmissions
do LoadDataVMT
do VMTIVEmissions

// Gas Use
do LoadDataGasUse
do GasUseIVEmissions


//End Timer
qui timer off 1
qui timer list 1
local minToComplete = `r(t1)'/60
if(`r(t1)'<60){
	di "Script took `r(t1)' seconds to complete."	
}
else{
	di "Script took `minToComplete' minutes to complete."	
}

cd "ReviewResponseResults"

translate "ReviewResponse.smcl" "ReviewResponse.pdf", replace

log close
